//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_PROGRAM_INTERFACE_H
#define _UX_PROGRAM_INTERFACE_H

#include "../Materials/IMaterial.h"

namespace Engine
{
namespace Resources
{


	struct TTextureInit
	{
		string				sName;		// uniform name or address
		GLSamplerSrc		sSampler;
		e_texture::type		eType;
		///
		TTextureInit(): sName(), eType(e_texture::UNKNOWN), sSampler() {}
		TTextureInit(const char *name, e_texture::type type, const GLSamplerSrc &sampler): sName(name), eType(type), sSampler(sampler) {}
	};
	

	struct TUniformTexture
	{
		gl_texture::type		eTarget;
		gl_tex_component::type	eCompType;
		GLuint					uLocation;
		uint					uSamplerID;
		e_texture::type			eType;
		///
		TUniformTexture():
			eTarget(gl_texture::_UNKNOWN), uLocation(-1), eType(e_texture::UNKNOWN),
			uSamplerID(0), eCompType(gl_tex_component::NONE) {}
		
		TUniformTexture(gl_texture::type target, gl_tex_component::type comptype, GLuint loc, e_texture::type type, uint sampler):
			eTarget(target), uLocation(loc), eType(type), eCompType(comptype), uSamplerID(sampler) {}
	};



	//
	// Program interface
	//

	class _EXPORT_ IProgram : public CResource
	{
	public:
		struct TUBValue
		{
			static_string<32>		sName;
			usize					uOffset;
			uint					uCount;
			gl_uniform::type		eType;
			///
			TUBValue(): sName(), uOffset(0) {}
			
			TUBValue(const uni_c_string &name, usize offset, gl_uniform::type type, uint count):
				sName(name), uOffset(offset), eType(type), uCount(count) {}
		};

		struct TUniformBlock
		{
			array<TUBValue>			aValues;
			uint					uBindingIndex;
			uint					uSize;
			e_program_data::type	eDataType;
			///
			TUniformBlock(): eDataType(e_program_data::UNKNOWN), uBindingIndex(-1), uSize(0) {}
		};

	public:
		virtual void  Bind(const uni_array<const uint32> &aStages) = 0;
		virtual bool  LinkTextures(const uni_array<const TMaterialTexture> &aTextures, uni_array<uint32> aStages) = 0;
		virtual bool  GetUniformBlock(e_program_data::type eType, TUniformBlock const *&pUB) const = 0;
	};
	
//-------------------------------------------------------------------

}	// Resources
}	// Engine

#endif	// _UX_PROGRAM_INTERFACE_H